Recurse through items in a DOORS database

I need to create a text file (or comma separated CSV file) with the following information please:

For each item (projects, folders, modules) in DOORS database root node, recursively traverse and output

each item full path, item creation date, name of user who created, last updated, user name of who last updated?

Is it possible to create a dxl script that recursively traverses through the ROOT node of a DOORS database please?

Or Do I have to run such script from each folder or project?

How to run such DXL script? Can I run the DXL script from any open module?

Any suggestions or high level steps please?

Thanks in advance for any ideas.

Mike

 

 

 


MikeMelon - Mon Nov 17 15:16:50 EST 2014

Re: Recurse through items in a DOORS database
sekrbo - Wed Nov 19 10:23:56 EST 2014

This should get your Items

Item iRef

Folder f = folder ("/")


void projectContent (Project p) {
    for iRef in p do {
        print fullName (iRef) "\n"
    }
}

void folderContent (Folder f) {
    for iRef in f do {
        print fullName (iRef) "\n"
        if (type (iRef) == "Folder") then {
            folderContent (folder (iRef))
        } elseif (type (iRef) == "Project") then {
            projectContent (project (iRef))
        }
    }
}

folderContent (f)

/sekrbo

Re: Recurse through items in a DOORS database
MikeMelon - Wed Nov 19 12:05:03 EST 2014

sekrbo - Wed Nov 19 10:23:56 EST 2014

This should get your Items

Item iRef

Folder f = folder ("/")


void projectContent (Project p) {
    for iRef in p do {
        print fullName (iRef) "\n"
    }
}

void folderContent (Folder f) {
    for iRef in f do {
        print fullName (iRef) "\n"
        if (type (iRef) == "Folder") then {
            folderContent (folder (iRef))
        } elseif (type (iRef) == "Project") then {
            projectContent (project (iRef))
        }
    }
}

folderContent (f)

/sekrbo

Hi Kristian (sekrbo),

This is a great script. Worked as it is without any changes. I ran the script from DOORS database root node and it listed items very fast.

This sample script is excellent starting point. I can add more output features that I have listed in my question above.

Many, many thanks for the DXL script.

Best regards,

Mike

 

Re: Recurse through items in a DOORS database
MikeMelon - Wed Nov 19 13:58:27 EST 2014

MikeMelon - Wed Nov 19 12:05:03 EST 2014

Hi Kristian (sekrbo),

This is a great script. Worked as it is without any changes. I ran the script from DOORS database root node and it listed items very fast.

This sample script is excellent starting point. I can add more output features that I have listed in my question above.

Many, many thanks for the DXL script.

Best regards,

Mike

 

I have a question about the above DXL script by sekrbo please:

If a project contains one or more folders(i.e. sub-folders) will this script work as it is or do I need to modify by adding if type(iRef) statements in the projectContent function also?

If so, do I need to forward declare folderContent function? How to forward declare folderContent ?

Thanks,

Mike

 

 

Re: Recurse through items in a DOORS database
MikeMelon - Wed Nov 19 14:36:12 EST 2014

MikeMelon - Wed Nov 19 13:58:27 EST 2014

I have a question about the above DXL script by sekrbo please:

If a project contains one or more folders(i.e. sub-folders) will this script work as it is or do I need to modify by adding if type(iRef) statements in the projectContent function also?

If so, do I need to forward declare folderContent function? How to forward declare folderContent ?

Thanks,

Mike

 

 

void folderContent (Folder)

 

I have added the above forward declaration and also added if - else if statements in projectContent function similar to the folderContent function.

The script is printing the output but it is going through infinite loop. I have terminated the process from task manager.

Any clues to stop never ending recursion please?

Thanks

Mike

 

Re: Recurse through items in a DOORS database
sekrbo - Thu Nov 20 02:00:03 EST 2014

MikeMelon - Wed Nov 19 14:36:12 EST 2014

void folderContent (Folder)

 

I have added the above forward declaration and also added if - else if statements in projectContent function similar to the folderContent function.

The script is printing the output but it is going through infinite loop. I have terminated the process from task manager.

Any clues to stop never ending recursion please?

Thanks

Mike

 

The difference between "for itemRef in project do" and "for itemRef in all folder do" is that in project, loops recursively through contained folders and projects, but in folder does not. Which means you do not have to worry about forward declaring folderContent. If you add the "if then" yes you'll be getting the same items from different loops, the main in projectContent and again in folderContent. If there are projects in a folder in a project, well I think you can see the problem :) However, I did see something, that is bad, the fact that I use a global variable in the loops, it should work as it is only used once for the recursive calles, but it's bad programming...

Folder f = folder ("/")

void projectContent (Project p) {
    Item iRef
    for iRef in p do {
        print fullName (iRef) "\n"
    }
}

void folderContent (Folder f) {
    Item iRef
    for iRef in f do {
        print fullName (iRef) "\n"
        if (type (iRef) == "Folder") then {
            folderContent (folder (iRef))
        } elseif (type (iRef) == "Project") then {
            projectContent (project (iRef))
        }
    }
}

folderContent (f)

 

/sekrbo

Re: Recurse through items in a DOORS database
MikeMelon - Thu Nov 20 09:37:34 EST 2014

sekrbo - Thu Nov 20 02:00:03 EST 2014

The difference between "for itemRef in project do" and "for itemRef in all folder do" is that in project, loops recursively through contained folders and projects, but in folder does not. Which means you do not have to worry about forward declaring folderContent. If you add the "if then" yes you'll be getting the same items from different loops, the main in projectContent and again in folderContent. If there are projects in a folder in a project, well I think you can see the problem :) However, I did see something, that is bad, the fact that I use a global variable in the loops, it should work as it is only used once for the recursive calles, but it's bad programming...

Folder f = folder ("/")

void projectContent (Project p) {
    Item iRef
    for iRef in p do {
        print fullName (iRef) "\n"
    }
}

void folderContent (Folder f) {
    Item iRef
    for iRef in f do {
        print fullName (iRef) "\n"
        if (type (iRef) == "Folder") then {
            folderContent (folder (iRef))
        } elseif (type (iRef) == "Project") then {
            projectContent (project (iRef))
        }
    }
}

folderContent (f)

 

/sekrbo

Hi sekrbo,

Thanks a bunch for clarification.

I understood your inputs.

I made minor changes as shown below and the script is going into infinite loop and repeatedly giving ""DXL contains 2 errors" message box every minute or so.

I have added "if else statement" in each of the two for loops.

Can you please let me know how to fix infinite loop?

pragma runLim, 0

void projectContent (Project p)
{
    Module newMod = null
    Date last_modified_date

    Item iRef
    for iRef in p do
 {  
     if (type (iRef) == "Formal") then
  {
      newMod = read(fullName(iRef), false)
      last_modified_date = newMod."Last Modified On"
   close(newMod)
   print fullName (iRef) ","
   print last_modified_date " \n"
  }
  else
  {
     print fullName (iRef) "\n"
  }
    }
}

void folderContent (Folder f)
{
    Module newMod = null
    Date last_modified_date

    Item iRef
    for iRef in f do
 {
     if (type (iRef) == "Formal") then
  {
      newMod = read(fullName(iRef), false)
      last_modified_date = newMod."Last Modified On"
   close(newMod)
   print fullName(iRef) ","
   print last_modified_date " \n"
  }
  else
  {
     print fullName (iRef) "\n"
  }
  
        if (type (iRef) == "Folder") then
  {
            folderContent (folder (iRef))
        }
  else if (type (iRef) == "Project") then
  {
            projectContent (project (iRef))
        }
    }
}

Folder f = folder ("/")
folderContent (f)

 

 

 

 

Re: Recurse through items in a DOORS database
MikeMelon - Thu Nov 20 10:36:15 EST 2014

MikeMelon - Thu Nov 20 09:37:34 EST 2014

Hi sekrbo,

Thanks a bunch for clarification.

I understood your inputs.

I made minor changes as shown below and the script is going into infinite loop and repeatedly giving ""DXL contains 2 errors" message box every minute or so.

I have added "if else statement" in each of the two for loops.

Can you please let me know how to fix infinite loop?

pragma runLim, 0

void projectContent (Project p)
{
    Module newMod = null
    Date last_modified_date

    Item iRef
    for iRef in p do
 {  
     if (type (iRef) == "Formal") then
  {
      newMod = read(fullName(iRef), false)
      last_modified_date = newMod."Last Modified On"
   close(newMod)
   print fullName (iRef) ","
   print last_modified_date " \n"
  }
  else
  {
     print fullName (iRef) "\n"
  }
    }
}

void folderContent (Folder f)
{
    Module newMod = null
    Date last_modified_date

    Item iRef
    for iRef in f do
 {
     if (type (iRef) == "Formal") then
  {
      newMod = read(fullName(iRef), false)
      last_modified_date = newMod."Last Modified On"
   close(newMod)
   print fullName(iRef) ","
   print last_modified_date " \n"
  }
  else
  {
     print fullName (iRef) "\n"
  }
  
        if (type (iRef) == "Folder") then
  {
            folderContent (folder (iRef))
        }
  else if (type (iRef) == "Project") then
  {
            projectContent (project (iRef))
        }
    }
}

Folder f = folder ("/")
folderContent (f)

 

 

 

 

With the DOORS database that I have, "there are projects in a folder in a project".  And the recursion going through infinite loop.

Is there a simple way to stop infinite loop in this DXL script?

Thanks

Mile

Re: Recurse through items in a DOORS database
Tony_Goodman - Thu Nov 20 11:24:21 EST 2014

MikeMelon - Thu Nov 20 10:36:15 EST 2014

With the DOORS database that I have, "there are projects in a folder in a project".  And the recursion going through infinite loop.

Is there a simple way to stop infinite loop in this DXL script?

Thanks

Mile

Try the Inventory of items script http://www.smartdxl.com/content/?p=438

Tony

Re: Recurse through items in a DOORS database
MikeMelon - Thu Nov 20 20:53:37 EST 2014

Tony_Goodman - Thu Nov 20 11:24:21 EST 2014

Try the Inventory of items script http://www.smartdxl.com/content/?p=438

Tony

Hi Tony,

Thanks a bunch for the excellent DXL script "Inventory of Items".

It ran and gave the output results.

However, the script is giving following error:

<Line:2> could not open include file (src/lib/compare/ComparisonIncludes.inc) (No such file or directory)

<Line:2> syntax error

The script is giving "DXL contains 2 errors" message box every few minutes or so.

Thanks again for the nice script.

Best regards,

Mike

 

 

 

Re: Recurse through items in a DOORS database
Tony_Goodman - Fri Nov 21 08:18:33 EST 2014

MikeMelon - Thu Nov 20 20:53:37 EST 2014

Hi Tony,

Thanks a bunch for the excellent DXL script "Inventory of Items".

It ran and gave the output results.

However, the script is giving following error:

<Line:2> could not open include file (src/lib/compare/ComparisonIncludes.inc) (No such file or directory)

<Line:2> syntax error

The script is giving "DXL contains 2 errors" message box every few minutes or so.

Thanks again for the nice script.

Best regards,

Mike

 

 

 

Glad it helped.

The error you mention is most likely in a DXL Attribute in one of your modules.

Tony

Re: Recurse through items in a DOORS database
MikeMelon - Fri Nov 21 12:28:57 EST 2014

Tony_Goodman - Fri Nov 21 08:18:33 EST 2014

Glad it helped.

The error you mention is most likely in a DXL Attribute in one of your modules.

Tony

Hi Tony,

Thanks a lot for the clue about the error due to "DXL Attribute". 

I will locate the module by running your script for one folder at a time.

Again thanks a bunch for your help.

Best regards,

Mike